﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class page_TestGridView : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter("select * from news", @"data source=192.168.1.23;initial catalog=northwind;user id=sa;password=lislis");
        da.Fill(ds, "id");
        DataView dv = ds.Tables[0].DefaultView;

        if (ViewState["id"] != null)
        {
            dv.Sort = ViewState["id"].ToString() + " " + ViewState["state"].ToString();
        }

        GridView1.DataSource = dv;
        GridView1.DataBind();

    }
}
